<template>
  <div class="goodsMask page flex-col">
    <!-- 头部 -->
    <div class="header">
      <Swipe :data.sync="swiperImgs" />
    </div>
    <!-- 基本信息 -->
    <div class="info">
      <div class="info-img">
        <img src="../../static/icones/detail_banner.png" alt="" />
      </div>
      <div class="info-content flex-col">
        <div class="content-title">
          <div class="titless">
            <span class="title">
              <span class="brandnew">全新</span
              ><span class="newtitle"
                >{{
                  goodsInfo.name ||
                  "苹果13Promax 5G手机 全新国行苹果13P苹果13Promax 5G手机 全新国行苹果13P全新国行苹果13P苹果全新国行苹果13P苹果"
                }}
              </span></span
            >
          </div>
          <div class="namess flex-row">
            <span
              class="nametip"
              v-for="(item, index) in info.labelsString"
              :key="index"
              >{{ item || "九个字全网通全网通" }}</span
            >
          </div>
          <div class="tip-box flex-col">
            <span class="top"
              >当前页面内容为订单快照,包含订单创建时的商品描述和下单信息,
              买卖双方和平台在发生交易争议时，该页面作为判定依据。</span
            >
            <span class="views">点击查看最新商品详情></span>
          </div>
        </div>
      </div>
    </div>

    <!-- 订单信息 -->
    <div class="orderInfo flex-col">
      <div class="item">
        <span class="name">已选套餐</span>
        <span class="text">{{ info.specName }}</span>
      </div>
      <div class="item">
        <span class="name">发货方式</span>
        <span class="text">{{ info.num || "寄出到付 | 归还自付" }}</span>
      </div>
      <div class="item">
        <span class="name">数量</span>
        <span class="text">{{ info.num }}</span>
      </div>
      <div class="item">
        <span class="name">租赁时间</span>
        <span class="text">{{ info.startEndTimeString }}</span>
      </div>
      <div class="item line">
        <span class="name">快照时间</span>
        <span class="text">{{ info.createTime || "" }}</span>
      </div>
      <div class="item">
        <span class="name">日租金</span>
        <span class="text">￥{{ info.rentFee }}</span>
      </div>
      <div class="item">
        <span class="name">总租金</span>
        <span class="text">{{ info.allRentFee }}</span>
      </div>
      <div class="item">
        <span class="name">买断价</span>
        <span class="text">{{ info.buyoutFee }}</span>
      </div>
      <div class="item">
        <span class="name">设备押金</span>
        <span class="text">{{ info.supplementaryDeposit || 0 }}</span>
      </div>
    </div>
    <!-- 详情 -->
    <div class="goods-tabs">
      <div class="tabs justify-around items-center">
        <div
          class="item flex-col justify-center"
          :class="{ select: currentTab === index }"
          v-for="(tab, index) in tabs"
          :key="`tab${index}`"
          @tap="changeTab(index)"
        >
          <span>{{ tab }}</span>
        </div>
      </div>

      <view class="taro_html" v-if="currentTab == 0">
        <u-parse :content="goodsDetails"></u-parse>
      </view>
      <div class="taro_html" v-if="currentTab == 1">
        <u-parse :content="rentInstructions"></u-parse>
      </div>
      <!-- <QA v-if="currentTab === 2" />

      <GoodsComment v-show="currentTab === 3" /> -->
      <div class="tips flex-col">
        <p class="title">温馨提示</p>
        <div class="content">
          点击“免押租”按钮后即默认您已阅读和接受上述产品页面信息，且
          回意授权平台将您的个人信息用于租赁交易的风险评估。
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getgoodsMark } from "../../config/api";
import Swipe from "../goods_detail/components/swipe.vue";
export default {
  name: "goodsMask",
  components: { Swipe },
  data() {
    return {
      orderId: "",
      swiperImgs: [], // 轮播图
      info: [],
      tabs: ["商品介绍", "租赁说明"], //商品详情
      currentTab: 0,
      goodsDetails: "",
    };
  },
  mounted() {
    // const { id } = this.$query();
    // if (id) {
    //   this.orderId = id;
    // }
    this.getOrderInfo();
  },
  computed: {},
  methods: {
    async getOrderInfo() {
      const res = await getgoodsMark({
        orderId: 50582,
        sessionId: "c22eeb72a2abdc87a2e8b2c6865d230d_61985",
      });
      console.log(res, "jjjjjj");
      this.info = res.data?.orderDetailDTO;
      this.swiperImgs = res.data?.orderDetailDTO.images.includes(";")
        ? res.data?.orderDetailDTO.images.split(";")
        : [res.data?.orderDetailDTO.images];
      this.info.labelsString = res.data?.orderDetailDTO.labelsString.includes(
        ";"
      )
        ? res.data?.orderDetailDTO.labelsString.split(";")
        : [res.data?.orderDetailDTO.labelsString];
      // this.goodsDetails = res.data?.orderDetailDTO.goodsDetails;
      // console.log(res.data?.orderDetailDTO.goodsDetails, "[[[");
    },
    //商品详情切换
    changeTab(index) {
      this.currentTab = index;
      console.log(this.currentTab, index, "--=---");
    },
  },
};
</script>
<style lang="scss">
.goodsMask {
  width: 100vw;
  background-color: #f5f5f5;
  .info {
    width: 100%;
    min-height: 88px;
    background-color: #fff;
    overflow: auto;
    .info-img {
      width: 100%;
      height: 88rpx;
      img {
        width: 100%;
        height: 100%;
        object-fit: contain;
      }
    }
    .info-content {
      min-height: 204px;
      padding: 0 15px;
      //   overflow: auto;

      .content-title {
        width: 100%;
        min-height: 204px;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        .titless {
          font-size: 15px;
          color: #3d3d3d;
          .title {
            display: flex;
            .brandnew {
              min-width: 36px;
              height: 18px;
              line-height: 18px;
              border-radius: 9px;
              background-color: #157afe;
              margin-right: 10px;
              font-size: 12px;
              color: #fff;
              text-align: center;
            }
            .newtitle {
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 2;
              margin-top: -6px !important;
            }
          }
        }
        .namess {
          width: 100%;
          height: 20px;
          line-height: 20px;
          font-size: 10px;
          color: #6d6d6d;

          .nametip {
            min-width: 100px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            border-radius: 11px;
            padding: 0 12px;
            background: rgba(0, 0, 0, 0.05);
            margin-right: 10px;
          }
        }
        .tip-box {
          width: 100%;
          min-height: 88px;
          background-color: #f8f8f8;
          padding: 12px;
          color: #9d9d99;
          border-radius: 5px;
          font-size: 12px;
          line-height: 18px;
          font-family: PingFang SC Medium;
          .views {
            color: #157afe;
            text-align: right;
          }
        }
      }
    }
  }
  .orderInfo {
    width: 100%;
    min-height: 354px;
    margin-top: 10px;
    padding: 15px;
    background-color: #fff;
    font-size: 14px;
    font-family: PingFang SC Medium;
    color: #3d3d3d;
    .item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 36px;
      // padding-bottom: 8px;
      &.line {
        border-bottom: 1px solid #e4e4e4;
      }
    }
  }

  .goods-tabs {
    padding: 0 10px;
    width: 100%;
    margin-top: 8px;
    margin-bottom: 50px;
    background-color: #fff;
    .tabs {
      height: 57px;
      // border-bottom: 1px solid #37A9FF;
      z-index: 100;
      padding: 0 10px;
      width: 100%;
      .item {
        font-size: 16px;
        color: #333333;
        position: relative;
        transition: color 0.3s;
        height: 28px;
        line-height: 30px;
        text-align: center;
        font-size: 14px;
        border-radius: 14px;
        width: 76px;
        &.select {
          background-color: #0096ff;
          color: #ffffff;
        }
        // .line {
        //   position: absolute;
        //   left: 0;
        //   bottom: 0;
        //   width: 100%;
        //   height: 4px;
        //   background: #37A9FF;
        //   border-radius: 2px;
        // }
      }
    }
    .taro_html {
      image {
        width: 100%;
        height: auto;
      }
    }
    .tips {
      height: 94px;
      margin-top: 12px;
      padding-bottom: 12px;
      margin-left: 14px;
      margin-bottom: 10px;
      .title {
        color: #3d3d3d;
        font-size: 14px;
      }
      .content {
        color: #6d6d6d;
        font-size: 12px;
        margin-top: 6px;
        line-height: 18px;
      }
    }
  }
}
</style>
